
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
void main() {
  runApp(MyApp());
}
class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home:ConfirmOrder(),
    );
  }

}
bool IsClick = true;
bool IsCancel = true;
class ConfirmOrder extends StatefulWidget {
  @override
  ConfirmOrderState createState() => new ConfirmOrderState();
}

class ConfirmOrderState extends State<ConfirmOrder> {
  @override
  SDia(){
    if(IsClick==true){
      showDialog(
          context:context,
          barrierDismissible: false,
          builder: (BuildContext context){
            return DemoDialog();
          }
      );
    }

  }
  CDia(){
    if(IsClick==true){
      showDialog(
          context:context,
          barrierDismissible: false,
          builder: (BuildContext context){
            return TureDialog();
          }
      );
    }

  }
  Widget build(BuildContext context) {

    return  MaterialApp(
      home: Scaffold(
        backgroundColor: Color.fromRGBO(236,236,236, 1),
        appBar: AppBar(
          backgroundColor: Color.fromRGBO(51, 51, 51, 1),
          titleSpacing: 0.0,
          title:Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              FlatButton(
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                child: Row(
                  children: [
                    Icon(Icons.arrow_back_ios,color: Colors.white,),
                    Text('返回',style: TextStyle(color: Colors.white,fontSize: 16),)
                  ],
                ),
                onPressed:(){
                  Navigator.pop(context);
                },
              ),
              Container(child: Row(children: [
                Text('跑腿待付款详情',style: TextStyle(fontSize: 16),),
                SizedBox(width: 25,)
              ],),),
              IconButton(icon: Icon(Icons.more_horiz), onPressed: (){})
            ],
          ),
          bottom: PreferredSize(
            preferredSize: Size.fromHeight(90),
            child: Column(
              children: <Widget>[
                //任务已被接单
                Container(
                  height: 80,
                  padding: EdgeInsets.only(left: 15,top: 10,bottom: 10),
                  color: Colors.white,
                  child: Row(
                    children: <Widget>[
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text("任务已被接单",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)),
                          SizedBox(height: 8,),
                          Text("接单时间：2017-6-20 18:00",style: TextStyle(fontSize: 16))
                        ],
                      )
                    ],
                  ),
                ),
                Container(
                  height: 10,
                  decoration: BoxDecoration(
                    color: Color.fromRGBO(236,236,236, 1),
                  ),
                )
              ],
            ),
            // preferredSize: Size.fromHeight(80.0)
          ),
        ),
        body: Container(
          child: Column(
            children: <Widget>[
              Expanded(
                child: SingleChildScrollView(
                  child: Column(
                    children: <Widget>[

                      SizedBox(height: 10,),
                      //跑腿待付款（金额内容地址）
                      Container(
                        padding: EdgeInsets.only(left: 15,right: 15,top:10 ,bottom: 10),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[

                            //跑腿待付款
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: <Widget>[
                                Text("跑腿",style: TextStyle(fontSize: 14),),
                                Spacer(),
                                Text("待确认",style: TextStyle(color: Colors.red,fontSize: 16),textAlign: TextAlign.right,)
                              ],
                            ),
                            SizedBox(height: 10,),
                            Text("任务主题（限制20字）",style: TextStyle(fontSize: 18),),
                            SizedBox(height: 20,),
                            //分割线
                            Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                            //已支付
                            Row(
                              children: <Widget>[

                                Icon(Icons.attach_money,color:Color.fromRGBO(51, 51, 51, 0.5),),

                                Text("  已支付：5元",style: TextStyle(fontSize: 16))
                              ],
                            ),
                            SizedBox(height: 10,),
                            //任务内容
                            Container(
                              width: 300,
                              child: Row(
                                children: <Widget>[
                                  Icon(Icons.message,color:Color.fromRGBO(51, 51, 51, 0.5),),
                                  Expanded(
                                    child: Padding(
                                      padding: EdgeInsets.only(left: 10,top: 12),
                                      child: Text('任务内容任务内容任务内容任务内容任务内容任务内容任务内容任务内容',style: TextStyle(fontSize: 16),),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            SizedBox(height: 20,),
                            //分割线
                            Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                            //发单人姓名地址电话
                            Row(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: <Widget>[
                                Icon(Icons.location_on,color:Color.fromRGBO(51, 51, 51, 0.5),),
                                Text("  发单人姓名         15688888888  ",style: TextStyle(fontSize: 16)),
                              ],
                            ),
                            SizedBox(height: 8,),
                            Text("          福建省厦门市",style: TextStyle(fontSize: 13)),
                            SizedBox(height: 30,),
                            //分割线
                            Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                            SizedBox(height: 8,),
                            //  发布时间
                            Row(
                              children: <Widget>[

                                Icon(Icons.access_time,color:Color.fromRGBO(51, 51, 51, 0.5),),

                                Text("  发布时间：2017-6-20 18:00",style: TextStyle(fontSize: 16))
                              ],
                            ),
                            SizedBox(height: 10,),
                          ],
                        ),

                        decoration: BoxDecoration(
                            color: Colors.white
                        ),
                      ),
                      SizedBox(height: 10,),
                      //接单信息
                      Container(
                        padding: EdgeInsets.only(left: 15,right: 15,top:10 ,bottom: 10),
                        decoration: BoxDecoration(
                            color: Colors.white
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Text("  接单信息",style: TextStyle(fontSize: 16)),
                            Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                            Row(
                              children: <Widget>[
                                Icon(Icons.account_circle,color:Color.fromRGBO(51, 51, 51, 0.5),),
                                Text("  接单人姓名             13988888888",style: TextStyle(fontSize: 16)),
                              ],
                            ),
                            Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Icon(Icons.phone,color:Color.fromRGBO(51, 51, 51, 0.5),size: 30,),
                                Text("  电话接单人",style: TextStyle(fontSize: 16)),
                              ],
                            ),
                            Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                            Row(
                              children: <Widget>[

                                Icon(Icons.access_time,color:Color.fromRGBO(51, 51, 51, 0.5),),

                                Text("  接单时间：2017-6-20 18:00",style: TextStyle(fontSize: 16))
                              ],
                            )
                          ],
                        ),
                      )
                    ],
                  ),
                ),
              ),
              //取消订单 确认完成!!!按钮
              Offstage(
                  child: Container(
                    height: 50,
                    decoration: BoxDecoration(
                        border: Border(top: BorderSide(color: Colors.grey,width: 1)),
                        color: Colors.white
                    ),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        RaisedButton(
                          color: Color.fromRGBO(255,255,255,1),
                          disabledColor: Colors.blue,
                          disabledTextColor: Colors.white,
                          onPressed: (){
                            setState(() {
                              SDia();
                            });
                          },
                          child: new Text('取消订单'),
                          shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(3.0),
                              side: BorderSide(color: Colors.black,width: 0.5)),

                        ),
                        Text("   "),
                        MaterialButton(
                            color: Colors.grey,
                            child: new Text('确认完成',style: TextStyle(color: Colors.white),),
                            shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(3.0),
                                side: BorderSide(color: Colors.grey,width: 0.5)),
                            onPressed: (){
                              setState(() {
                                CDia();
                              });
                            }
                        ),
                        Text("   ")
                      ],
                    ),

                  ),
                  offstage: !IsCancel
              ),

            ],
          ),
        ),
      ),
    );
  }
}


//取消提示弹窗
class DemoDialog extends StatefulWidget {
  @override
  DemoDialogState createState() => new DemoDialogState();
}

class DemoDialogState extends State<DemoDialog> {
  String dropdownValue = '原因1';
  @override
  Widget build(BuildContext context) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 320.0,
          height: 200.0,
          child: Container(
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                SizedBox(height: 10,),
                Text("取消提示",style: TextStyle(fontSize: 16),),
                SizedBox(height: 20,),
                Padding(
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child: Center(
                      child: Text("由于你的单已有人接单，若想取消该单，请联系接单人同意取消订单，若接单人不同意则无法成功取消。",style: TextStyle(fontSize: 16),textAlign: TextAlign.center,),
                    )
                ),

                Spacer(),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor:Color.fromRGBO(255,255,255,0),
                            child: Text("继续取消"),
                            onPressed: (){
                              setState(() {
                                IsCancel = false;
                                IsClick = false;
                                showDialog(
                                    context:context,
                                    barrierDismissible: false,
                                    builder: (BuildContext context){
                                      return AlertDemoDialog();
                                    }
                                ).then((value) {
                                  setState(() {
                                    Navigator.pop(context,{IsCancel,IsClick});
                                  });
                                }//then
                                );
                              });//setState
                            },//onpressed
                          ),
                        ),
                        decoration: BoxDecoration(
                          border: new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    )
                    ,
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor:Color.fromRGBO(255,255,255,0),
                            child: Text("再考虑考虑"),
                            onPressed: (){
                              IsClick=true;
                              Navigator.pop(context,{IsCancel,IsClick});
                            },
                          ),
                        ),
                        decoration: BoxDecoration(
                          border: new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    )
                  ],
                ),

              ],
            ),
          ),
        ),
      ),
    );
  }

}




//继续取消提示弹窗
class AlertDemoDialog extends StatefulWidget {
  @override
  AlertDemoDialogState createState() => new AlertDemoDialogState();
}

class AlertDemoDialogState extends State<AlertDemoDialog> {
  @override
  Widget build(BuildContext context) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 320.0,
          height: 200.0,
          child: Container(
            padding: EdgeInsets.all(10),
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                //提示
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    SizedBox(width: 20,),
                    Text("提示",style: TextStyle(fontSize: 16)),
                    Container(
                      child: FlatButton(
                        color: Colors.white,
                        child: Icon(Icons.close),
                        onPressed: (){
                          setState(() {
                            Navigator.pop(context,IsCancel);
                          });
                        },
                      ),
                      height: 40,
                      width: 40,
                      decoration: BoxDecoration(
                          border: new Border.all(color: Colors.white, width: 1),
                          borderRadius: BorderRadius.all(Radius.circular(50)),
                          color: Colors.white
                      ),
                    ),

                  ],
                ),
                //消息已发出，等待接单人回复
                SizedBox(height: 50,),
                Text("消息已发出，等待接单人回复",textAlign: TextAlign.center,style: TextStyle(fontSize: 16))
              ],
            ),
          ),
        ),
      ),
    );
  }
}




//确认完成提示弹窗
class TureDialog extends StatefulWidget {
  @override
  TureDialogState createState() => new TureDialogState();
}

class TureDialogState extends State<TureDialog> {
  @override
  Widget build(BuildContext context) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 320.0,
          height: 200.0,
          child: Container(
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                SizedBox(height: 10,),
                Text("成功提示",style: TextStyle(fontSize: 16),),
                SizedBox(height: 40,),
                Padding(
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child: Center(
                      child: Text("是否确认完成该单？",style: TextStyle(fontSize: 20),textAlign: TextAlign.center,),
                    )
                ),

                Spacer(),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor:Color.fromRGBO(255,255,255,0),
                            child: Text("确认完成"),
                            onPressed: (){

                            },
                          ),
                        ),
                        decoration: BoxDecoration(
                          border: new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    )
                    ,
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor:Color.fromRGBO(255,255,255,0),
                            child: Text("取消"),
                            onPressed: (){
                              Navigator.pop(context);
                            },
                          ),
                        ),
                        decoration: BoxDecoration(
                          border: new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    )
                  ],
                ),

              ],
            ),
          ),
        ),
      ),
    );
  }
}




